// Code Behind for usermanager.mxml
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import jcrweb.as3.FlexUtil;
	import jcrweb.as3.RequestUtil;
	import mx.controls.Alert;
	import mx.managers.PopUpManager;
	import jcrweb.as3.LanguageUtil;
	[Bindable]
	private var languageUtil:LanguageUtil;
	[Bindable]
	[Embed(source='../WebContent/images/error.gif')]
	private var iconError:Class;
	
    private function init():void {
		languageUtil = LanguageUtil.getInstance();
	}


	private function submit():void{
		if(input_name.text == ""){
			Alert.show("Please input name.","Error",0,null,null,iconError);
			return;
		}
		if(input_code.text == ""){
			Alert.show("Please input code.","Error",0,null,null,iconError);
			return;
		}
		if(input_password.text == ""){
			Alert.show("Please input password ","Error",0,null,null,iconError);
			return;
		}
		var para:String = new String();
		para +="&userName="+input_name.text;
		para +="&userCode="+input_code.text;
		para +="&password="+input_password.text;
		para +="&perpath="+input_permission.text;
		para +="&mail="+input_mail.text;
		para +="&note="+input_note.text;
		para =  encodeURI(para);
		para =  encodeURI(para);
		var url:String = RequestUtil.CREATEUSER_URL+para;
		RequestUtil.sendRequest(url,Event.COMPLETE,complete);
	}
	public function complete(event:Event):void {
		var loader:URLLoader = URLLoader(event.target); 
		var isError:String = FlexUtil.getTag(loader.data,FlexUtil.IS_ERROR);
		if(isError == "true" ){
			var errorMes:String = FlexUtil.getTag(loader.data,FlexUtil.ERROR_MES_TAG);
			Alert.show("Create directory faild! "+errorMes,"Error",0,null,null,iconError);
		}
		closeDialog();
	}
	private function closeDialog():void{
		PopUpManager.removePopUp(this);
	}
	private function reset():void{
		input_name.text = "";
		input_code.text = "";
		input_password.text = "";
		input_permission.text = "";
		input_mail.text = "";
		input_note.text = "";
	}
	private function showPermissionset():void{
		var myPanel:permissionset = permissionset(PopUpManager.createPopUp(this, permissionset, true));
		myPanel.input_usercode.text = this.input_code.text;
		myPanel.input_username.text = this.input_name.text;
		myPanel.input_perdir.text = this.input_permission.text;
		
		myPanel.setReturnobj(this.input_permission);
		PopUpManager.centerPopUp(myPanel);
	}
	private function keyDownEvent(keyCode:uint):void{
			if(keyCode == 27){
				this.closeDialog();
			}
	}